package com.yiren.dbaa.module.practice_set.carmodel.presenter;

import android.app.Activity;

import com.yiren.backstage.config.api.LoadConfigApi;
import com.yiren.backstage.config.bean.device.UserParamConfigBean;
import com.yiren.backstage.currency.entity.CarModelEntity;
import com.yiren.dbaa.currency.api.CommonCallBack;
import com.yiren.dbaa.module.practice_set.carmodel.contract.CarModelHomeContract;
import com.yiren.dbaa.module.practice_set.carmodel.contract.OpenCarmodelContract;
import com.yiren.dbaa.module.practice_set.carmodel.model.CarModelHomeModel;
import com.yiren.dbaa.module.practice_set.carmodel.model.OpenCarmodelModel;

/**
 * @author lwb
 * @date : 2022/12/6 9:01
 * @description: 公开车模
 */
public class OpenCarmodelPresenter implements OpenCarmodelContract.Presenter {

     private Activity activity;
     private OpenCarmodelContract.Model openCarmodelModel;
     private CarModelHomeContract.Model homeCarmodelModel;

    public OpenCarmodelPresenter(Activity activity) {
        this.activity = activity;
        openCarmodelModel = new OpenCarmodelModel(activity);
        homeCarmodelModel = new CarModelHomeModel(activity);
    }

    @Override
    public void loadOpenCarmodel(String userId, CommonCallBack callBack) {
        //从服务器获取线路
        UserParamConfigBean userParamConfigBean = LoadConfigApi.loadUserParamConfig(activity);
        homeCarmodelModel.getCarModelFromServer(userParamConfigBean.getUserInfo().getId().toString(),true,callBack);
    }

    @Override
    public void setCarModelState(int state, CarModelEntity carModel, CommonCallBack callBack) {
        openCarmodelModel.changeCarModelState(state,carModel,callBack);
    }
}
